Component({
  data: {
    movieslist: [],
    cardCur: 0,
    swiperList: [{
      id: 0,
      type: 'image',
      url: '../../../images/tabbar/top250.png'
    }],
  },
  created: function () {
    wx.showLoading({
      title: '正在加载',
    })
    let that = this;
    const db = wx.cloud.database();
    const movies = db.collection("movies");
    movies.orderBy('rate', 'desc').get({
      success: function (resp) {
        resp.data.forEach((item) => {
          //这里需要截取的内容
          item.author = item.author.substring(0, 15) + "..."
        })
        that.setData({
          movieslist: resp.data
        })
        wx.hideLoading()
      },
      fail: function (error) {
        return error
      }
    })
  },
  methods: {
    // 跳转到详情
    todetail: function (options) {
      wx.navigateTo({
        url: '/pages/comm/detail/detail?id=' + options.currentTarget.dataset.id,
      })
      wx.showToast({
        title: options.currentTarget.dataset.id
      })
    }
  }
})